<template>
    <div id="navMenu">
        <el-menu
            default-active="2"
            class="el-menu-vertical-demo"
            @open="handleOpen"
            @close="handleClose"
            background-color="#545c64"
            text-color="#fff"
            active-text-color="#ffd04b"
            style="border:none"
        >
            <el-submenu v-for="(item,key,index) in allMenus" :key="key" :index="String(index)">
                <template slot="title">
                    <i class="el-icon-location"></i>
                    <span>{{item.permissionDesc}}</span>
                </template>
                <el-menu-item v-for="(permission,permissionIndex) in item.children" 
                :key="permissionIndex" :index="index+'-'+permissionIndex"
                @click="pushToView({name:permission.permissionDesc})">
                    {{permission.permissionDesc}}
                </el-menu-item>
            </el-submenu>
        </el-menu>
    </div>
</template>
<script>
export default {
    methods: {
        handleOpen(){},
        handleClose(){}
    },
    computed: {
        allMenus(){
            return this.$store.getters.allMenus;
        }
    },
    mounted(){
        var menus = JSON.parse(localStorage.getItem('response')).permissions;
        // console.log("存储在本地的数据");
        // console.log(menus);
        this.$store.commit('LOADALLMENUS',menus)
    }
}
</script>
<style lang="scss" scoped>
    #navMenu{
        width: 200px;
        height: 100%;
        background: rgb(84, 92, 100);
    }
</style>
